<?php
/*
 * @Author: 笔青居
 * @Date: 2018-10-31 14:57:46
 * @lastEditors: 白酒煮饭
 * @LastEditTime: 2019-06-13 23:46:09
 * @Description: 在笔青居代码的基础上增加接收参数功能
 */
 $id = $_GET['user'];
 function gbkToUtf8($s){
     if(false){
         return iconv('gbk','utf-8',$s);
     }
     return $s;
 }

$list=array();
function fileList($path){
    $files=scandir($path);
    foreach ($files as $file){
        global $list;
        $temp=array();
        if($file=="."||$file==".."){
            continue;
        }
        $name=$path.$file;
        if(is_file($name)){
          $temp["type"]="1";
          $temp["fileName"]=gbkToUtf8($file);
          $temp["filePath"]=gbkToUtf8(substr($path,11));
          $temp["md5"]=md5_file($name);
          $temp["updataTime"]=filectime($name);
          array_push($list,$temp);
        }else{
          $temp["type"]=0;
          $temp["fileName"]=gbkToUtf8($file);
          $temp["filePath"]=gbkToUtf8(substr($path,10));
          array_push($list,$temp);
          fileList($name."/");
        }
    }
}

fileList("AutoJs_Code/".$id."/");
print_r(json_encode($list));
?>